package com.qn.visitor.analyze.ipaddressr;

import com.qn.visitor.resources.config.IpAddressrTypeUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
 * qingniu-cloud user source analysis
 *
 * @Author: TXG
 * @Date: 2024/6/11
 * @Version V0.0.2
 */
@Component
public class IpAddressrProperties {
    /**
     * IP解析器类型（Ip2region、Cz88、Ipwhois）
     * 默认使用Ip2region
     */
    @Value("${qingniu.ipAddressr.type}")
    private String ipAddressrType;
    public String getIpAddressrType() {
        return ipAddressrType;
    }

    public Integer getIpAddressrTypeInt() {
        if (ipAddressrType == null) {
            return 1;
        } else if (ipAddressrType.equals(IpAddressrTypeUtils.IP2REGION)) {
            return 1;
        } else if (ipAddressrType.equals(IpAddressrTypeUtils.CZ88)) {
            return 2;
        } else if (ipAddressrType.equals(IpAddressrTypeUtils.IPWHOIS)) {
            return 3;
        } else {
            return 1;
        }
    }

    public void setIpAddressrType(String ipAddressrType) {
        this.ipAddressrType = ipAddressrType;
    }
}
